"""
    自定义Process类，实现创建子进程并执行任务
"""

import multiprocessing
import os

# 自定义Process类，继承自multiprocessing.Process类
class Worker(multiprocessing.Process): 
    def run(self):
        print(f"子进程 pid: {os.getpid()}, 父进程 pid: {os.getppid()}")


if __name__ == "__main__":
    print(f"主进程 pid: {os.getpid()}")
    for _ in range(5):
        p = Worker()
        p.start()